home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / lang / Python16_Src.lha / Python16_Source / Python / dynload_hpux.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-03  |  1.3 KB  |  54 lines

  1. /* Support for dynamic loading of extension modules */
  2.  
  3. #include "dl.h"
  4. #include <errno.h>
  5.  
  6. #include "Python.h"
  7. #include "importdl.h"
  8.  
  9. #if defined(__hp9000s300)
  10. #define FUNCNAME_PATTERN "_init%.200s"
  11. #else
  12. #define FUNCNAME_PATTERN "init%.200s"
  13. #endif
  14.  
  15. const struct filedescr _PyImport_DynLoadFiletab[] = {
  16.     {".sl", "rb", C_EXTENSION},
  17.     {"module.sl", "rb", C_EXTENSION},
  18.     {0, 0}
  19. };
  20.  
  21. dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
  22.                     const char *pathname, FILE *fp)
  23. {
  24.     dl_funcptr p;
  25.     shl_t lib;
  26.     int flags;
  27.     char funcname[258];
  28.  
  29.     flags = BIND_FIRST | BIND_DEFERRED;
  30.     if (Py_VerboseFlag) {
  31.         flags = DYNAMIC_PATH | BIND_FIRST | BIND_IMMEDIATE |
  32.             BIND_NONFATAL | BIND_VERBOSE;
  33.         printf("shl_load %s\n",pathname);
  34.     }
  35.     lib = shl_load(pathname, flags, 0);
  36.     /* XXX Chuck Blake once wrote that 0 should be BIND_NOSTART? */
  37.     if (lib == NULL) {
  38.         char buf[256];
  39.         if (Py_VerboseFlag)
  40.             perror(pathname);
  41.         sprintf(buf, "Failed to load %.200s", pathname);
  42.         PyErr_SetString(PyExc_ImportError, buf);
  43.         return NULL;
  44.     }
  45.     sprintf(funcname, FUNCNAME_PATTERN, shortname);
  46.     if (Py_VerboseFlag)
  47.         printf("shl_findsym %s\n", funcname);
  48.     shl_findsym(&lib, funcname, TYPE_UNDEFINED, (void *) &p);
  49.     if (p == NULL && Py_VerboseFlag)
  50.         perror(funcname);
  51.  
  52.     return p;
  53. }
  54.